package com.qfedu.demo.springcloud.stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

@SpringBootApplication
@EnableBinding({Sink.class, QfInputChannel.class}) // 绑定接收器
public class StreamConsumer {

	private Logger LOG = LoggerFactory.getLogger(StreamConsumer.class);
	
	/**
	 * 消息接收处理逻辑
	 * @param msg
	 */
	@StreamListener(Sink.INPUT)// 指定消息接收代码，绑定默认的input频道
	public void receiveMsg (String msg) {
		LOG.info("receiveMsg:" + msg);
	}
	
	/**
	 * 消息接收处理逻辑
	 * @param msg
	 */
	@StreamListener("qfInputChannel")// 指定消息接收代码，绑定qfInputChannel频道
	public void receiveMsg2 (String msg) {
		LOG.info("receiveMsg2:" + msg);
	}
	
	public static void main(String[] args) {
		SpringApplication.run(StreamConsumer.class, args);
	}

}
